<?php
class cmd{

	public static function cookie($param){
		// set cookie
		if(is_array($param)){
			$cookie = new CHttpCookie($param[0], $param[1]);
			$cookie->expire = time()+60*60*24*180;
			Yii::app()->request->cookies[$param[0]] = $cookie;
			return $param[1];
		} else {
		// read cookie
			$cookies = Yii::app()->request->getCookies();
			return isset($cookies[$param]->value) ? $cookies[$param]->value : null;
		}
	}
	
}